package net.kuratkoo.jidelnicekvut;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class Preferences extends PreferenceActivity {
    private static final String TAG = "JidelnicekVUT|Preferences";

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
        addPreferencesFromResource(R.xml.preferences);
    }

    public static String getString(Context context, String name, String defaultValue) {
	return PreferenceManager.getDefaultSharedPreferences(context).getString(name, defaultValue);
    }

    public static void setString(Context context, String name, String value) {
      SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
      SharedPreferences.Editor editor = settings.edit();
      editor.putString(name, value);
      editor.commit();
    }

    public static Boolean getBoolean(Context context, String name, Boolean defaultValue) {
	return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(name, defaultValue);
    }

    public static void setBoolean(Context context, String name, Boolean value) {
      SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
      SharedPreferences.Editor editor = settings.edit();
      editor.putBoolean(name, value);
      editor.commit();
    }

}
